package com.cityfood.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cityfood.common.pojo.CityFoodResult;
import com.cityfood.pojo.CfCompany;
import com.cityfood.service.CompanyService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



@Controller
public class CompanyController {
	
	@Autowired
	private CompanyService companyService;

    //调试微信支付
    private static Logger logger = LoggerFactory.getLogger(CompanyController.class);
	
	/**
	 * 根据公司信息id查询公司信息
	 */
	@RequestMapping(value="/companyInfo",method=RequestMethod.GET)
	@ResponseBody
	public CityFoodResult getCompany(@RequestParam(defaultValue="1")Integer companyId){
	    CityFoodResult cityFoodResult = new CityFoodResult();
		CfCompany company = companyService.getCompanyById(companyId);
		if (company!=null) {
            logger.debug("获取城市信息成功！");
			cityFoodResult.setCode(200);
			cityFoodResult.setMsg("查询公司信息成功");
			cityFoodResult.setData(company);
			return cityFoodResult;
		}
        logger.debug("获取城市信息失败！");
		cityFoodResult.setCode(201);
		cityFoodResult.setMsg("查询公司信息失败");
		cityFoodResult.setData("");
		return cityFoodResult;
		
	}

}
